﻿using AlgorithmInterview.Chapter03._01;

namespace AlgorithmInterview.Chapter03._08;

/// <summary>
/// 后序遍历法
/// </summary>
public class Test03
{
    public static BiTNode FindParentNode(BiTNode root, BiTNode node1, BiTNode node2)
    {
        if (root == null || root == node1 || root == node2)
            return root;
        BiTNode lchild = FindParentNode(root.Lchild, node1, node2);
        BiTNode rchild = FindParentNode(root.Rchild, node1, node2);
        if (lchild == null)
            return rchild;
        else if (rchild == null)
        {
            return lchild;
        }
        else
        {
            return root;
        }
    }
}